package com.spzx.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.order.domain.OrderInfo;
import com.spzx.order.domain.OrderItem;
import com.spzx.order.mapper.OrderInfoMapper;
import com.spzx.order.service.IOrderInfoService;
import com.spzx.order.service.IOrderItemService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService{

    @Resource
    private IOrderItemService orderItemService;
    @Override
    public List<OrderInfo> selectOrderInfoList(OrderInfo orderInfo)    {
        return baseMapper.selectOrderInfoList(orderInfo);
    }

    @Override
    public OrderInfo getOrderInfoById(Long id) {
        OrderInfo orderInfo = getById(id);
        List<OrderItem> list = orderItemService.list(new LambdaQueryWrapper<OrderItem>().eq(OrderItem::getOrderId, id));
        orderInfo.setOrderItems(list);
        return orderInfo;
    }
}
